package nl.hva.three2learn.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Table(name = "progress_test")
@Entity
public final class ProgressTest implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8747605570310222830L;

	@Id
	@GeneratedValue
	@Column(name = "progress_test_id")
	private long id;
	
	@Column(name = "description", length = 1024)
	private String description;	
	
	@OneToMany(cascade = { CascadeType.DETACH, CascadeType.REMOVE })
	@LazyCollection(LazyCollectionOption.FALSE)
	private List<Question> questions;
	
	public ProgressTest() { }
	
	public ProgressTest(String description) {
		this.questions = new ArrayList<Question>();
		this.description = description;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public long getId() {
		return this.id;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getDescription() {
		return this.description;
	}
	
	public void setQuestionS(List<Question> questions) {
		this.questions = questions;
	}
	
	public void addQuestion(Question question) {
		questions.add(question);
	}
	
	public List<Question> getQuestions() {
		return this.questions;
	}
	
	public void removeQuestion(int index) {
		this.questions.remove(index);
	}
}
